<template>
	<view>
		<view class="list">
			<view class="list-one" v-for="(item, list) in consultlist" :key="list">
				<view class="cont">
					<view class="tit two">
						<b style="display: contents">姓名：</b>
						{{ item.name }}
					</view>
					<view class="time" style="margin-top: 12rpx; display: flex">
						<b style="display: contents">性别：</b>
						{{ item.sex }}
					</view>
					<view class="time" style="margin-top: 12rpx; display: flex">
						<b style="display: contents">年龄：</b>
						{{ item.age }}
					</view>
					<view class="time" style="margin-top: 12rpx; display: flex">
						<b style="display: contents">年龄：</b>
						{{ item.degree }}
					</view>
					<view class="bottm">
						<b style="display: contents">个人情况：</b>
						<u-parse :content="item.info"></u-parse>
					</view>
					<view class="time" style="margin-top: 12rpx; display: flex">
						<b style="display: contents">申请原因：</b>
						{{ item.applyReason }}
					</view>
					<view class="time" style="margin-top: 12rpx; display: flex">
						<b style="display: contents">就业目标：</b>
						{{ item.jobName }}
					</view>
					<view class="time" style="font-weight: bold; display: flex" @click="call_phone(item.contactMobile)">
						联系电话：
						<u--text :text="item.contactMobile" color="#8BB950" bold></u--text>
					</view>
					<view class="time" style="text-align: right">{{ item.createTime }}</view>
					<view class="time" style="margin-top: 12rpx; display: flex" v-if="item.dealInfo">
						<b style="display: contents">处理意见：</b>
						{{ item.dealInfo }}
					</view>
					<view class="time" style="text-align: right" v-if="item.dealTime">{{ item.dealTime }}</view>
				</view>
			</view>
		</view>
		<u-empty :show="consultlist.length == 0 && loading ? true : false" marginTop="100"></u-empty>
		<u-loadmore :status="loadstatus" line v-if="consultlist.length > 0" />
		<view style="height: 140rpx"></view>
		<view class="btn" @click="show = true">
			<view class="topval">发布</view>
			<view class="bottmval">就业帮扶</view>
		</view>
		<u-popup :show="show" @close="close" :round="10" closeable>
			<view class="popup-tit">发布就业帮扶</view>
			<view class="popup-cont">
				<view class="tit">姓名</view>
				<view class="text">
					<u--input v-model="formdata.name" placeholder="请输入姓名"></u--input>
				</view>
				<view class="tit">性别</view>
				<view class="text">
					<u--input v-model="formdata.sex" placeholder="请输入性别"></u--input>
				</view>
				<view class="tit">年龄</view>
				<view class="text">
					<u--input v-model="formdata.age" placeholder="请输入年龄"></u--input>
				</view>
				<view class="tit">学历</view>
				<view class="text">
					<u--input v-model="formdata.degree" placeholder="请输入学历"></u--input>
				</view>
				<view class="tit">联系电话</view>
				<view class="text">
					<u--input v-model="formdata.contactMobile" placeholder="请输入联系电话"></u--input>
				</view>
				<view class="tit">申请原因</view>
				<view class="text">
					<u--textarea v-model="formdata.applyReason" placeholder="请输入申请原因" count></u--textarea>
				</view>
				<view class="tit">就业目标</view>
				<view class="text">
					<u--input v-model="formdata.jobName" placeholder="请输入就业目标"></u--input>
				</view>
				<view class="tit">个人情况介绍</view>
				<view class="text">
					<u--textarea v-model="formdata.info" placeholder="请输入个人情况介绍" count></u--textarea>
				</view>
				<view style="color: red; font-size: 24rpx" v-if="errtext">{{ errtext }}</view>
				<view class="btns" @click="click_idea">发布</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
import { jybfpageApply, jybfcreate } from '@/api/index.js';
import { commonUpload } from '@/api/mine.js';
export default {
	data() {
		return {
			consultlist: [],
			queryParams: {
				pageNo: 1,
				pageSize: 10
			},
			show: false,
			loading: false,
			loadstatus: 'loading',
			formdata: {
				name: '',
				sex: '',
				age: '',
				degree: '',
				contactMobile: '',
				applyReason: '',
				jobName: '',
				info: ''
			},
			errtext: ''
		};
	},
	onLoad() {
		this.get_zjzx();
	},
	methods: {
		call_phone(number) {
			uni.makePhoneCall({
				phoneNumber: number
			});
		},
		click_idea() {
			console.log(this.formdata);
			if (
				!this.formdata.name ||
				!this.formdata.sex ||
				!this.formdata.age ||
				!this.formdata.degree ||
				!this.formdata.contactMobile ||
				!this.formdata.applyReason ||
				!this.formdata.jobName ||
				!this.formdata.info
			) {
				uni.$u.toast('请填写内容');
				// this.errtext = '请填写内容';
				return;
			}
			jybfcreate(this.formdata).then((res) => {
				if (res.code == '0') {
					uni.$u.toast('发布成功，请等待审核');
					this.queryParams.pageNo = 1;
					this.consultlist = [];
					this.get_zjzx();
					this.close();
				} else {
					uni.$u.toast(res.msg);
					// this.errtext = res.msg;
				}
			});
		},
		close() {
			this.show = false;
			this.errtext = '';
			this.formdata = {
				name: '',
				sex: '',
				age: '',
				degree: '',
				contactMobile: '',
				applyReason: '',
				jobName: '',
				info: ''
			};
		},
		get_zjzx() {
			jybfpageApply(this.queryParams).then((res) => {
				this.loading = true;
				if (res.data.list.length == 0 && this.queryParams.pageNo > 1) {
					this.loadstatus = 'nomore';
					return;
				}
				if (this.queryParams.pageNo == 1 && res.data.list.length < 10) {
					this.loadstatus = 'nomore';
				}
				this.consultlist = this.consultlist.concat(res.data.list);
				this.queryParams.pageNo = res.data.list.length == 0 ? this.queryParams.pageNo : (this.queryParams.pageNo += 1);
			});
		}
	},
	onPullDownRefresh() {
		this.queryParams.pageNo = 1;
		this.consultlist = [];
		this.get_zjzx();
	},
	onReachBottom() {
		this.get_zjzx();
		this.loadstatus = 'loading';
	}
};
</script>

<style lang="scss">
.list {
	padding: 24rpx;

	.list-one {
		padding: 12rpx;
		display: flex;
		background: #ffffff;
		box-shadow: 0px 8rpx 40rpx 0px rgba(0, 0, 0, 0.1);
		border-radius: 12rpx;
		margin-bottom: 20rpx;

		.cont {
			flex: auto;

			.tit {
				font-size: 28rpx;
				font-weight: bold;
				line-height: 36rpx;
				min-height: 72rpx;
			}

			.bottm {
				margin-top: 12rpx;
				font-size: 24rpx;
				line-height: 36rpx;
				color: #666666;
				min-height: 108rpx;
			}

			.red {
				color: red;
			}

			.time {
				margin-top: 12rpx;
				color: #666666;
				font-size: 24rpx;
				line-height: 36rpx;
			}
		}
	}
}

.btn {
	position: fixed;
	top: 50%;
	z-index: 9;
	right: 12rpx;
	width: 182rpx;
	height: 206rpx;
	text-align: center;
	background: url('../../../static/index/btn.png') no-repeat;
	background-size: 100% 100%;
	color: #3c6d09;
	font-size: 24rpx;

	.topval {
		text-indent: 1em;
		margin-top: 120rpx;
		line-height: 36rpx;
	}

	.bottmval {
		text-indent: 1em;
		line-height: 36rpx;
	}
}

.popup-tit {
	line-height: 44rpx;
	padding-top: 48rpx;
	text-align: center;
}

.popup-cont {
	padding: 24rpx 48rpx 48rpx;
	max-height: 800rpx;
	overflow: auto;

	.tit {
		text-align: left;
		font-size: 26rpx;
		line-height: 44rpx;
		font-weight: bold;
		margin-top: 12rpx;
		margin-bottom: 12rpx;
	}

	.text {
		margin: 0;
		border: 2rpx solid #d8d8d8;
		border-radius: 12rpx;
	}

	.btns {
		margin: 64rpx;
		height: 88rpx;
		background: #8bb950;
		border-radius: 20rpx;
		color: #fff;
		text-align: center;
		line-height: 88rpx;
	}
}
</style>
